<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>WebOffice</title>
</head>
<script src="/admin/html/module/weboffice/js/web-office-sdk-solution-v2.0.5.umd.js"></script>
<body>
<script>


    window.onload = () => {

    }


    async function setData(data) {

        const instance = WebOfficeSDK.init({
            // officeType: WebOfficeSDK.OfficeType.Writer,
            officeType: WebOfficeSDK.OfficeType.Pdf,
            appId: 'SX20240422DGJWTO',
            fileId: data.id
        })

        console.log("instance",instance);
        // 需要等待实例 ready 之后再调用 API
        await instance.ready()
        const app = instance.Application

        console.log("app",app);

        //发现有缺失的字体
        app.Sub.FontMissing = e => {
            console.log(e)
        }

        //监听新增评论
        app.Sub.AddComment = async e => {
            console.log(e)

            // 字体对象
            const font = await app.ActiveDocument.Range(e.pos, e.pos+e.len).Font

            // 设置选定文字的高亮颜色
            font.HighLight = '#FFFF00'
        }



    }
</script>
</body>
</html>
